<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绑定手机号</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="full-screen" content="yes"/>
    <meta name="browsermode" content="application"/>
    <!-- QQ强制竖屏 QQ强制全屏 -->
    <meta name="x5-orientation" content="portrait"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="x5-page-mode" content="app"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="../../css/reset.css">
    <link rel="stylesheet" type="text/css" href="../../css/main.css">
    <link rel="stylesheet" type="text/css" href="../../css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/member.css">
    <link rel="stylesheet" type="text/css" href="/wap/e_tpl/css/new.css">
    <style>
        .header-wrap {
            background: #f8f8f8;
            height: 50px;
            margin-top: 0;
        }
        .l-btn-login{
            background:#eee;
            color:#333;
        }
        header {
            background: #f8f8f8;
            height: 60px;
        }
    </style>
</head>
<body>
<header id="header"></header>
<div class="login-form">
    <form action="" name="" id="" method="">
            <span>
                <input type="text" placeholder="手机号码" class="input-40" name="mobile_phone" id="mobile_phone"/>
            </span>
            <span>
                <input type="text" placeholder="请输入6位短信校验码" class="input-40" name="mobile_verify" id="mobile_verify"/>
            </span>
            <span>
                <a href="javascript:" id="getPhoneCode"> <strong>获取验证码</strong> </a>
            </span>

        <div class="error-tips mt10"></div>
        <a href="javascript:void(0);" class="l-btn-login mt10" id="checkbtn">注册</a>
    </form>
</div>
<div class="footer" id="footer"></div>
<input type="hidden" name="referurl">

<script type="text/javascript" src="../../js/config.js"></script>
<script type="text/javascript" src="../../js/zepto.min.js"></script>
<script type="text/javascript" src="../../js/template.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/tmpl/common-top.js"></script>
<script type="text/javascript" src="../../js/simple-plugin.js"></script>
<script type="text/javascript" src="../../js/tmpl/footer.js"></script>
<script>
    $(function(){

        var coldDown = function(elem){
            elem.unbind('click',send_message);

            var count = 60;
            var timer = setInterval(function(){
                elem.find('strong').text('重发短信（' + count + '）');

                if(--count == 0){
                    elem.bind('click',send_message);
                    elem.find('strong').text('获取短信校验码');
                    clearInterval(timer);
                }

            },1000);
        }


        var send_message = function(){
            var mobile = $.trim($('#mobile_phone').val());
            if(!/^1[345789][0-9]{9}$/.test(mobile)){
                alert('请输入正确的机号码！');
                return;
            }
            var mobile_error = 0x01 << 1;
            var error = 0x01 << 3;

            $.get('/shop/index.php?act=seccode&op=mobile_send_message',{mobile : mobile},function(msg){

                if(msg & mobile_error){
                    alert('手机号码错误！');
                    return;
                }

                if(msg & error){
                    alert('发送失败，请稍后重试！');
                    return;
                }

                //成功的处理
                alert('短信发送成功');
                coldDown($('#getPhoneCode'));

            });
        }

        $('#getPhoneCode').bind('click',send_message);


        $('#checkbtn').click(function(){
            var mobile = $.trim($('#mobile_phone').val());
            if(!/^1[345789][0-9]{9}$/.test(mobile)){
                alert('请输入正确的机号码！');
                return;
            }
            var mobile_verify = $.trim($('#mobile_verify').val());
            if(!/[0-9]{6}/.test(mobile_verify)){
                alert('请输入正确的手机验证码');
                return;
            }
           location.href = '/wap/jssdk/wechat_login.php?mobile='+mobile+'&mobile_verify='+mobile_verify+'&ref=<?php echo $_GET['ref']?>//';
        })
    });
</script>
</body>
</html>